package com.zhaosc.spark

import org.apache.spark.sql.SparkSession

object HiveDemo {

  def main(args: Array[String]): Unit = {
   
    val sparkSession = SparkSession.builder()
      .master("local")
      .enableHiveSupport()
      .appName("hive").getOrCreate();

    val rdd = sparkSession.read.format("jdbc")
       .option("url", "jdbc:hive2://hiveserver.58dns.org:10000/hdp_lbg_ecdata_dw_defaultdb")
      .option("driver", "org.apache.hive.jdbc.HiveDriver")
      .option("dbtable", "t_imc_active_userid")
      .option("user", "hdp_ubu_wuxian")
      .option("password", "")
      .load().rdd
      
      rdd.foreach(r => println(r.get(0)))
  }
}